Skip to content

Terminology for agent versus "standard" values in extensive games#642

Merged
tturocy merged 38 commits intomasterfrom
dev_terminology
Jan 2, 2026
Merged

Terminology for agent versus "standard" values in extensive games#642
tturocy merged 38 commits intomasterfrom
dev_terminology

Conversation

@tturocy
Copy link
Copy Markdown
Member

@tturocy tturocy commented Nov 24, 2025

This contains work for solving #617 .

Checklist of to-dos:

  • In Python and C++ the existing GetLiapValue/liap_value and GetMaxRegret/max_regret are prefixed by Agent/agent.
  • Existing tests and examples are updated to use agent terminology (but see action below!)
  • New functions enumpure_agent_solve and liap_agent_solve implemented and documented (and cross-linked with their non-agent versions)
  • GUI uses only the non-agent forms (for the avoidance of confusion to less experienced users; explicitly working with the agent form is an advanced topic suitable for CLI/pygambit use)
  • gambit-liap updated to follow convention of gambit-enumpure - default to using strategic form, use agent only if prompted explicitly to do so.
  • Implement liap_value and max_regret (and player regret) for MixedBehaviorProfile. These should be identical to their strategic equivalent.
  • Review all tests to see whether the agent or "regular" version should be used
  • Review all tutorials/user guide to see whether the agent or "regular" version should be used as examples (most likely the "regular" version is appropriate for general introductory tutorials)
  • Add tutorial/example covering Myerson's figure 4.2 example to illustrate the difference between standard Nash and agent Nash.

@tturocy tturocy requested a review from rahulsavani November 24, 2025 12:42
@tturocy tturocy linked an issue Nov 24, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Member

@rahulsavani rahulsavani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a lot to check here, but I believe everything is fine. Two minor things, the second of which is more general than this PR:

  1. enumpure_solve now has no use_strategic flag, but the NashComputationResult stills shows it as follows: NashComputationResult(method='enumpure', rational=True, use_strategic=True; similarly for enumpure_agent_solve where use_strategic is then False in the NashComputationResult. This might be fine as it indicates that type of the profiles under equilibria, but then perhaps that should be indicated another way rather than via this defunct argument?

  2. test_tutorials.py initially failed for me. On further inspection that was because it used a notebook checkpoint. I am not sure we want that behavior if it can be customized. If you agree we could ask Ed about looking into this.

@tturocy
Copy link
Copy Markdown
Member Author

tturocy commented Nov 25, 2025

use_strategic=True is set in the output object for all methods that use the strategic form, even those that do not have sequence form (or agent form) equivalents.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

# Conflicts:
#	doc/tutorials/03_stripped_down_poker.ipynb
#	src/games/stratmixed.h
#	src/pygambit/nash.pxi
#	src/tools/liap/liap.cc
#	tests/test_behav.py
#	tests/test_nash.py
@tturocy
Copy link
Copy Markdown
Member Author

tturocy commented Dec 8, 2025

@rahulsavani We now have the new, Nash-correct max_regret and liap_value implemented for mixed behaviour profiles. Or, at least, it should be correct - so you can now add your tests to this branch.

@tturocy tturocy requested a review from rahulsavani December 8, 2025 22:19
@rahulsavani
Copy link
Copy Markdown
Member

@rahulsavani We now have the new, Nash-correct max_regret and liap_value implemented for mixed behaviour profiles. Or, at least, it should be correct - so you can now add your tests to this branch.

It seems liap_value still comes back erroneously as 0 for the agent-but-not-full-Nash profile for Myserson's fig 4.2:

In [1]: import pygambit as gbt
   ...: g = gbt.read_efg('tests/test_games/myerson_fig_4_2.efg')
   ...: p = g.mixed_behavior_profile([[[0, 1], [0, 1]], [[1, 0]]])
   ...: print(p.max_regret())
   ...: print(p.agent_max_regret())
   ...: print(p.liap_value()) # incorrectly zero
   ...: print(p.agent_liap_value())
1.0
0.0
0.0
0.0

@tturocy
Copy link
Copy Markdown
Member Author

tturocy commented Dec 17, 2025

@rahulsavani We now have the new, Nash-correct max_regret and liap_value implemented for mixed behaviour profiles. Or, at least, it should be correct - so you can now add your tests to this branch.

It seems liap_value still comes back erroneously as 0 for the agent-but-not-full-Nash profile for Myserson's fig 4.2:

In [1]: import pygambit as gbt
   ...: g = gbt.read_efg('tests/test_games/myerson_fig_4_2.efg')
   ...: p = g.mixed_behavior_profile([[[0, 1], [0, 1]], [[1, 0]]])
   ...: print(p.max_regret())
   ...: print(p.agent_max_regret())
   ...: print(p.liap_value()) # incorrectly zero
   ...: print(p.agent_liap_value())
1.0
0.0
0.0
0.0

This was not one of my more clever moments. The C++ implementation is correct, it's just that liap_value was literally calling the wrong function (it was calling agent liap internally).

The branch has been updated with this fix. I've also merged in other work on clarifying mixed strategy profile cacheing proactively to fix other potential cache invalidation problems we haven't stumbled upon yet.

Assuming everything is working now, are we ready to merge or do we want to have the example set up as well?

@rahulsavani
Copy link
Copy Markdown
Member

Assuming everything is working now, are we ready to merge or do we want to have the example set up as well?

I will do some checks, and I can also do both final tasks, reviewing the tutorials/user guide and adding a tutorial on Myerson fig 4.2.

@rahulsavani
Copy link
Copy Markdown
Member

rahulsavani commented Dec 17, 2025

@tturocy: Before merging, it would be good if you could review the new consistency checks in tests/test_behav.py, already pushed.

@rahulsavani
Copy link
Copy Markdown
Member

@tturocy: I did a first draft of the notebook. Will check it carefully in the morning. I could incorporate any suggestions for changes then in case you get a chance to look before.

@rahulsavani
Copy link
Copy Markdown
Member

@edwardchalstrey1: There is now an advanced draft of a new notebook related to this PR, see:

04_agent_versus_non_agent_regret.ipynb

If you get a chance to take a look, feedback would be welcome. We should then also decide how we want to present it/link to it in the user guide.

@@ -0,0 +1,705 @@
{
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change 3 to 4


Reply via ReviewNB

@@ -0,0 +1,705 @@
{
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth offering a brief description of the game and if possible, what you might intuitively expect from the equilibria computation?


Reply via ReviewNB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would definitely be nice. I will check Myerson's text in case a useful description is given, but as I understand it, it is a pathological example constructed specifically to show the difference between agent and non-agent versions of these notions.

@@ -0,0 +1,705 @@
{
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, the tutorial that explains starting points is in the advanced_tutorials folder, if this assumes the reader has that knowledge already perhaps we need to reorder, or simply put this tutorial in the advanced folder and link to the other one here?


Reply via ReviewNB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is definitely not for non-expert users. As per my other reply to your comment, the agent versions are not actually particularly useful as I see it, but we have them already so we chose to keep them.

@@ -0,0 +1,705 @@
{
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the intended audience isn't likely to already know this, perhaps explain why computing these values is useful


Reply via ReviewNB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea -- it is meant to already be clear that we are interested in these being zero, as that gives a Nash eq, but I agree it will be useful to add that they are both measures of how close to equilibrium we are.

@edwardchalstrey1
Copy link
Copy Markdown
Member

@edwardchalstrey1: There is now an advanced draft of a new notebook related to this PR, see:

04_agent_versus_non_agent_regret.ipynb

If you get a chance to take a look, feedback would be welcome. We should then also decide how we want to present it/link to it in the user guide.

@rahulsavani nice, great to see draw_tree in action already! I have added some comments via ReviewNB - in short, it seems like this is intended to be a tutorial 4 read in the sequence of beginner tutorials, based on how you are describing the concepts/terminology throughout, so I suggested a few points of clarification or where detail could be added. However, I also note that this could go in the advanced tutorials instead, which would make this less necessary.

@rahulsavani
Copy link
Copy Markdown
Member

@rahulsavani nice, great to see draw_tree in action already! I have added some comments via ReviewNB - in short, it seems like this is intended to be a tutorial 4 read in the sequence of beginner tutorials, based on how you are describing the concepts/terminology throughout, so I suggested a few points of clarification or where detail could be added. However, I also note that this could go in the advanced tutorials instead, which would make this less necessary.

@edwardchalstrey1 :

Yes, draw_tree is great!

Thanks for the comments -- I put this new one in advanced_tutorials after all.

I also finished the penultimate task which involved replacing agent_max_regret and agent_liap_solve with the standard versions in 03_stripped_down_poker.ipynb. If you can check my work there that would be great.

@@ -39,7 +39,7 @@
},
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an extra sentence saying "We set use_strategic=True because..."


Reply via ReviewNB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent comment -- on reflection we should not use it, so I removed it!

@rahulsavani
Copy link
Copy Markdown
Member

@tturocy: I am done with this for now, this is ready to merge from my side, unless you have further suggestions for changes.

@tturocy tturocy marked this pull request as ready for review January 2, 2026 09:57
@tturocy tturocy merged commit b5ab74f into master Jan 2, 2026
26 checks passed
@tturocy tturocy deleted the dev_terminology branch January 2, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Make behavior profile terminology more transparent and consistent

3 participants